home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / QuickDraw3D 1.6 SDK / Mac SampleCode Previous / Geometry Samples- Mac / BoxMooV / sources / BoxMooV_event.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-18  |  2.6 KB  |  133 lines  |  [TEXT/CWIE]

  1. /*  event.c                                                                            
  2.  
  3.     This contains all the code for routing and handling events.
  4.                                                                                     
  5.     Rick Evans    - Sept. 1996    derived from BoxPaint_event.c
  6.     Michael Bishop - August 21 1996                                                    
  7.     Nick Thompson
  8.     (c)1994-96 Apple computer Inc., All Rights Reserved                                
  9.  
  10. */
  11.  
  12. /* --------------------------------------------------------------------
  13. ** Includes
  14. */
  15.  
  16. #include <Devices.h>
  17. #include <QuickDraw.h>
  18.  
  19. /*  for QuickDraw 3D */
  20. #include    "QD3D.h"
  21. #include    "QD3DMath.h"
  22. #include    "QD3DDrawContext.h"
  23. #include    "QD3DShader.h"
  24. #include    "QD3DTransform.h"
  25. #include    "QD3DGroup.h"
  26.  
  27. #include    "BoxMooV_event.h"
  28. #include    "BoxMooV_document.h"
  29. #include    "BoxPaint_menu.h"
  30. #include    "BoxMooV_window.h"
  31. #include    "BoxPaint_main.h"
  32.  
  33.  
  34.  
  35. /*    --------------------------------------------------------------------
  36. **    Event_HandleKeyPress
  37. **    Handles a Key pressed
  38. */
  39. void Event_HandleKeyPress(EventRecord *theEvent)
  40. {
  41.     char    key;
  42.  
  43.     key = theEvent->message & charCodeMask;
  44.     
  45.     /*  just check to see if we want to quit... */
  46.     
  47.     if ( theEvent->modifiers & cmdKey ) {        /* Command key down? */
  48.         Menu_HandleCommand(MenuKey(key));
  49.     } 
  50.  
  51. }
  52.  
  53. /*    --------------------------------------------------------------------
  54. **    Event_DoOSEvent
  55. **    Handles an OSEvent
  56. */
  57. void    Event_DoOSEvent(EventRecord theEvent)
  58. {    char    mask;
  59.  
  60.     mask = (theEvent.message >> 24) && 0xFF;
  61.  
  62.     switch(mask) {
  63.         case mouseMovedMessage:
  64.             break;
  65.         case suspendResumeMessage:
  66.             Event_DoSuspendResume(theEvent);
  67.             break;
  68.     }
  69. }
  70.  
  71. /*    --------------------------------------------------------------------
  72. **    Event_DoSuspendResume
  73. **    Does nothing at the moment
  74. */
  75. void    Event_DoSuspendResume(EventRecord theEvent)
  76. {
  77. /* Code doesn't work */
  78.     if((theEvent.message & resumeFlag) != 0)
  79.     {
  80.         gForeground = true;
  81.         gTicks = 5;
  82.     }
  83.     else
  84.     {
  85.         gForeground = false;
  86.         gTicks = 50;
  87.     }
  88. }
  89.  
  90.  
  91. /*    --------------------------------------------------------------------
  92. **    Event_DoNull
  93. **    Do this when your app is idle
  94. */
  95. void Event_DoNull(void)
  96. {
  97.     /*  we received a null event, rotate the cube */
  98.     WindowPtr        theWindow;
  99.     CGrafPtr            savedPort;
  100.  
  101.     GetPort((GrafPtr *)&savedPort);
  102.  
  103.     theWindow = FrontWindow() ;
  104.     
  105.     while( (theWindow != NULL) && gForeground)
  106.     {
  107.         Rect                theRect ;
  108.         DocumentHdl            theDocument;
  109.  
  110.         theDocument = Document_GetFromWindow( theWindow ) ;
  111.         
  112.         if(theDocument != NULL)
  113.         {
  114.             
  115.             HLock( (Handle)theDocument  ) ;
  116.             
  117.             theRect = ((CGrafPtr)theWindow)->portRect ;
  118.  
  119.             SetPort((GrafPtr)theWindow) ;
  120.             
  121.             Document_Animate(theDocument);
  122.             
  123.             InvalRect( &theRect ) ;
  124.  
  125.             HUnlock( (Handle)theDocument  ) ;
  126.         }
  127.                     
  128.         theWindow = Window_GetNextWindow(theWindow);
  129.     }
  130.     
  131.     SetPort((GrafPtr)savedPort);
  132. }
  133.